package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.result.ResultCodeEnum;
import com.atguigu.gmall.product.entity.BaseCategory1;
import com.atguigu.gmall.product.service.BaseCategory1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController     // @RestController  = @Controller(把当前的类交由spring容器进行管理) + @ResponseBody(把方法的返回值作为响应体输出给前端，如果方法的返回值是对象类型，会把对象转换json)
@RequestMapping(value = "/admin/product")
//@CrossOrigin            // 解决跨域问题
public class BaseCategory1Controller {  // Access-Control-Allow-Origin: "*", "*"

    @Autowired
    private BaseCategory1Service baseCategory1Service ;

    @GetMapping(value = "/getCategory1")
    public Result<List<BaseCategory1>> findAll() {
        List<BaseCategory1> baseCategory1List = baseCategory1Service.list();
        return Result.build(baseCategory1List , ResultCodeEnum.SUCCESS);
    }

}
